package com.iaz.tech.tools.property.impl;

import com.iaz.tech.tools.property.IPropertyAble;

import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 集合类属性，用于存储集合类
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PropertyCollection  extends Property {	
	/**
     * 日志
     */
	private final static Logger logger = (Logger) LoggerFactory.getLogger(PropertyCollection.class);
	
    /* 集合属性集合, 集合*/
    private Map<Long, byte[]> collection = new HashMap<Long, byte[]>();
    /* 属性 */
    private Map<Long, IPropertyAble> collectionProperty = new HashMap<Long, IPropertyAble>();
    
    @Override
    public IPropertyAble clone() {
        return null;
    }

    @Override
	public void push(Object _value) {
    	try {
    		if (_value == null) {
    			throw new Exception("入口参数为空！");
    		}
    		ValueProperty _new_property = new ValueProperty();
    		_new_property.push(_value);
    		_new_property.setPropDataType(_value.getClass());
    		Long _index = (long)collectionProperty.size();
    		collectionProperty.put(_index, _new_property);
    	} catch (Exception e) {
    		logger.error("执行异常：" + e.getMessage());
    	}
		
	}

	@Override
	public void push(IPropertyAble property) {
		try {
			if (property == null) {
				throw new Exception("入口参数property 没有指定。");
			}
			Long _index = (long)collectionProperty.size();
    		collectionProperty.put(_index, property);
		} catch (Exception e) {
    		logger.error("执行异常：" + e.getMessage());
    	}
	}

}
